//
//  GesturesViewController.swift
//  MyNavigationbar
//
//  Created by teleframe on 15/8/19.
//  Copyright (c) 2015年 tf. All rights reserved.
//

import UIKit

class GesturesViewController: UIViewController ,UIScrollViewDelegate{

    
@IBOutlet var scrollView: UIScrollView!
 var contentView: UIView!
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let width = self.view.bounds.width/2
        let height = self.view.bounds.height
        contentView = UIView(frame: CGRect(x: 0, y:-70, width: width, height: height+40))
        scrollView.contentSize = contentView.frame.size
        scrollView.addSubview(contentView)
       
        let btn : UIButton = UIButton(frame: CGRect(x: 0, y: 0, width: width, height: width))
        let s = CGFloat(255/149)
        btn.backgroundColor = UIColor.grayColor()
        btn.setTitle("按钮", forState: UIControlState.Normal)
        btn.tag = 1
        btn.addTarget(self, action: "actionEvent:", forControlEvents: UIControlEvents.TouchUpInside)
        self.contentView.addSubview(btn)
       
        let btn1 : UIButton = UIButton(frame: CGRect(x: 0, y: width, width: width, height: width))
        btn1.backgroundColor = UIColor.greenColor()
        btn1.setTitle("按钮", forState: UIControlState.Normal)
        btn1.tag = 2
        btn1.addTarget(self, action: "actionEvent:", forControlEvents: UIControlEvents.TouchUpInside)
        self.contentView.addSubview(btn1)
        
        let btn2: UIButton = UIButton(frame: CGRect(x: 0, y: width * CGFloat(2), width: width, height: width))
        btn2.backgroundColor = UIColor.yellowColor()
        btn2.setTitle("按钮", forState: UIControlState.Normal)
        btn2.tag = 3
        btn2.addTarget(self, action: "actionEvent:", forControlEvents: UIControlEvents.TouchUpInside)
        self.contentView.addSubview(btn2)
        
        let btn3: UIButton = UIButton(frame: CGRect(x: 0, y: width * CGFloat(3), width: width, height: width))
        btn3.backgroundColor = UIColor.orangeColor()
        btn3.setTitle("按钮", forState: UIControlState.Normal)
        btn3.tag = 4
        btn3.addTarget(self, action: "actionEvent:", forControlEvents: UIControlEvents.TouchUpInside)
        self.contentView.addSubview(btn3)
     }
    
    func actionEvent (sender: UIButton){
      print("tag==========\(sender.tag)")
    }
    
}
